﻿using System;
using System.Collections.Generic;
using System.Web;

/// <summary>
/// Summary description for So_PhieuKham
/// </summary>
public class So_PhieuKham
{
    #region local variables
    private string _sMaPK;
    private string _sMaKhoa;
    private DateTime _dtNgay;
    private string _sMaThuDV;
    private string _sMaBA;
    private string _sMaBN;
    private string _sNguonBN;
    private string _sTrieuChung;
    private string _sChanDoanSoBo;
    private string _sChanDoan;
    private string _sICDChanDoan;
    private string _sChanDoanPhu1;
    private string _sICDChanDoanPhu1;
    private string _sChanDoanPhu2;
    private string _sICDChanDoanPhu2;

    private string _sXuTri;

    private string _sChiDinhDieuTri;
    private string _sLoiDanBS;
    private string _sHenTaiKham;
    private DateTime _dtNgayTaiKham;
    private string _sMaBS;
    private string _sBacSiKham;
    private string _sChuyenDenKhoa;
    private string _sChuyenDenBV;
    private bool _bDaKeToa;
    private string _sDBName;
    private string _sMaDotKham;
    private string _sLoaiKham_CP;
    private string _sMaPK_Chinh;
    private string _sKetThucKham;
    private string _sMaPhieuCu;
    private bool _bIsAddNew;
    private string _sMsg;

    public string MaPK
    {
        get { return _sMaPK; }
        set
        {
            _sMaPK = value;
        }
    }
    public string MaKhoa
    {
        set { _sMaKhoa = value; }
        get { return _sMaKhoa; }
    }
    public DateTime Ngay { set { _dtNgay = value; } }

    public string MaThuDV
    {
        set { _sMaThuDV = value; }
    }

    public string MaBA { set { _sMaBA = value; } }
    public string MaBN
    {
        get { return _sMaBN; }
        set
        {
            _sMaBN = value;
        }
    }
    public string NguonBN { set { _sNguonBN = value; } }
    public string TrieuChung { set { _sTrieuChung = value; } }
    public string ChanDoanSoBo { set { _sChanDoanSoBo = value; } }
    public string ChanDoan { set { _sChanDoan = value; } }
    public string ICDChanDoan { set { _sICDChanDoan = value; } }
    public string ChanDoanPhu1 { set { _sChanDoanPhu1 = value; } }
    public string ICDChanDoanPhu1 { set { _sICDChanDoanPhu1 = value; } }
    public string ChanDoanPhu2 { set { _sChanDoanPhu2 = value; } }
    public string ICDChanDoanPhu2 { set { _sICDChanDoanPhu2 = value; } }
    public string XuTri { set { _sXuTri = value; } get { return _sXuTri; } }
    public string ChiDinhDieuTri { set { _sChiDinhDieuTri = value; } }
    public string LoiDanBS { set { _sLoiDanBS = value; } }
    public string HenTaiKham { set { _sHenTaiKham = value; } }
    public DateTime NgayTaiKham { set { _dtNgayTaiKham = value; } }
    public string MaBS { set { _sMaBS = value; } }
    public string BacSiKham { set { _sBacSiKham = value; } }
    public string ChuyenDenKhoa { set { _sChuyenDenKhoa = value; } }
    public string ChuyenDenBV { set { _sChuyenDenBV = value; } }

    public bool DaKeToa { set { _bDaKeToa = value; } }
    public string DBName { set { _sDBName = value; } }

    public string MaDotKham
    {
        get { return _sMaDotKham; }
        set
        {
            _sMaDotKham = value;
        }
    }
    public string LoaiKham_CP
    {
        get { return _sLoaiKham_CP; }
        set
        {
            _sLoaiKham_CP = value;
        }
    }

    public string MaPhieuKhamChinh { set { _sMaPK_Chinh = value; } }
    public string KetThucKham { set { _sKetThucKham = value; } }


    public string MaPhieuCu
    {
        get { return _sMaPhieuCu; }
        set { _sMaPhieuCu = value; }
    }
    public string Msg
    {
        get { return _sMsg; }
    }	

    #endregion

    private DAL_PhieuKham dal_PhieuKham;

	public So_PhieuKham()
	{
        dal_PhieuKham = new DAL_PhieuKham();
	}

    public bool addPhieuKham()
    {
        _sMsg = dal_PhieuKham.KTra_donthuocdaban(_sMaPK);
        if (_sMsg != "")
        {
            System.Web.HttpContext.Current.Response.Write(_sMsg);
            return false;
        }
        
        return dal_PhieuKham.addPhieuKham(_sMaPK, _sMaKhoa, _dtNgay, _sMaThuDV, _sMaBA, _sMaBN, _sNguonBN,
        _sTrieuChung, _sChanDoanSoBo, _sChanDoan, _sICDChanDoan, _sChanDoanPhu1, _sICDChanDoanPhu1,
        _sChanDoanPhu2, _sICDChanDoanPhu2, _sXuTri, _sChiDinhDieuTri, _sLoiDanBS, _sHenTaiKham,
        _dtNgayTaiKham, _sMaBS, _sBacSiKham, _sChuyenDenKhoa, _sChuyenDenBV, _bDaKeToa,
        _sDBName, _sMaDotKham, _sLoaiKham_CP, _sMaPK_Chinh, _sKetThucKham);
    }

    public bool updatePhieuKham()
    {
        _sMsg = dal_PhieuKham.KTra_donthuocdaban(_sMaPK);
        if (_sMsg != "")
        {
            System.Web.HttpContext.Current.Response.Write(_sMsg);
            return false;
        }

        bool bResult = dal_PhieuKham.updatePhieuKham(_sMaPK, _sMaKhoa, _dtNgay, _sMaThuDV, _sMaBA, _sMaBN, _sNguonBN,
            _sTrieuChung, _sChanDoanSoBo, _sChanDoan, _sICDChanDoan, _sChanDoanPhu1, _sICDChanDoanPhu1,
            _sChanDoanPhu2, _sICDChanDoanPhu2, _sXuTri, _sChiDinhDieuTri, _sLoiDanBS, _sHenTaiKham,
            _dtNgayTaiKham, _sMaBS, _sBacSiKham, _sChuyenDenKhoa, _sChuyenDenBV, _bDaKeToa,
            _sDBName, _sMaDotKham, _sLoaiKham_CP, _sMaPK_Chinh, _sKetThucKham);
        return bResult;
    }   

    public void deleteSo_PhieuKham(string MaPK)
    {
        dal_PhieuKham.deleteSo_PhieuKham(MaPK);
    }

    public void fnCapNhatKeToaDSChoKham(string MaDotKham, string MaKhoa)
    {
        dal_PhieuKham.fnCapNhatKeToaDSChoKham(MaDotKham, MaKhoa);
    }
}